package com.shxy.rlzy.entity;

import cn.hutool.core.util.IdcardUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDate;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * <p>
 * 
 * </p>
 *
 * @author tanhao
 * @since 2021-09-23
 */
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@TableName("emp_info")
public class EmployeeInfo extends BaseEntity {

    private static final long serialVersionUID = 1L;

    // 姓名
    @NotBlank(message = "姓名不能为空")
    private String name;

    // 身份证号
    @NotBlank(message = "身份证号不能为空")
    @Pattern(regexp = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([\\d|x|X]{1})$", message = "身份证号码不正确")
    private String idCard;
    @TableField(exist = false)
    private Integer age;
    @TableField(exist = false)
    private Integer gender;

    // 民族
    @NotBlank(message = "民族不能为空")
    private String ethic;
    // 籍贯
    @NotBlank(message = "籍贯不能为空")
    private String nativePlace;
    // 地址
    @NotBlank(message = "地址不能为空")
    private String address;
    // 健康状况
    @NotBlank(message = "健康状况不能为空")
    private String healthy;
    // 照片
    private String avatar;
    // 婚姻状态
    @NotBlank(message = "婚姻状态不能为空")
    private String maritalStatus;
    // 政治面貌
    @NotBlank(message = "政治面貌不能为空")
    private String politic;

    /**
     * 邮箱
     */
    @NotBlank(message = "电子邮箱不能为空")
    private String email;

    /**
     * 电话
     */
    @NotBlank(message = "电话不能为空")
    private String phone;

    /**
     * 职务
     */
    private String post = "无";

    // 部门编号
    @NotNull(message = "部门不能为空")
    private Long departId;

    @TableField(exist = false)
    private Depart depart;

    /**
     * 职位
     */
    private String position = "无";

    /**
     * 人员类型
     */
    @NotNull(message = "人员类型不能为空")
    private String roleType;

    /**
     * 合同起始时间
     */
    @NotNull(message = "合同起始时间不能为空")
    private LocalDate contactStart;

    /**
     * 合同期限
     */
    @NotBlank(message = "合同期限不能为空")
    private String contactPeriod;

    /**
     * 合同类型
     */
    @NotBlank(message = "合同类型不能为空")
    private String contactType;

    /**
     * 备注
     */
    private String remark;

    // 第一学历
    private String firstEduExp;
    private String firstDegree;
    private String firstMajor;
    private String firstSchool;

    // 最高学历
    private String lastEduExp;
    private String lastDegree;
    private String lastMajor;
    private String lastSchool;

    private String trainExp;    // 培训经历

    /**
     * 获取年龄
     * @return
     */
    public Integer getAge() {
        return IdcardUtil.getAgeByIdCard(idCard);
    }

    /**
     * 获取性别
     * @return
     */
    public Integer getGender() {
        return IdcardUtil.getGenderByIdCard(idCard);
    }
}
